package cn.pugle.oj.leetcode;

import cn.pugle.oj.catalog.DaiBi;

/**
 * https://leetcode.com/problems/maximum-product-subarray/
 *
 * @author tzp
 * @since 2020/9/17
 */
public class LC152 implements DaiBi {
    public int maxProduct(int[] nums) {
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < nums.length; i++) {
            int now = 1;
            for (int j = i; j < nums.length; j++) {
                now = nums[j] * now;
                max = Math.max(max, now);
            }
        }
        return max;
    }

    public static void main(String[] args) {
        System.out.println(new LC152().maxProduct(new int[]{2, 3, -2, 4}));
        System.out.println(new LC152().maxProduct(new int[]{-2, 0, -1}));
    }
}
